package com.xuxueli.commontdemo.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@HeadRowHeight(value = 40)
public class DemoExcel {


    /**
     * 姓名
     */
    @ExcelProperty(value = "姓名(必填)", index = 0)
    @ColumnWidth(value = 20)
    private String name;

    /**
     * 年龄
     */
    @ExcelProperty(value = "年龄(必填)", index = 1)
    @ColumnWidth(value = 20)
    private String age;

    /**
     * 重写equals和hashCode 用于使用
     * excelList.stream().distinct().collect(Collectors.toList()); 进行数据去
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DemoExcel demoExcel = (DemoExcel) o;
        return Objects.equals(name, demoExcel.name) &&
                Objects.equals(age, demoExcel.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}

